const bodyParser = require('body-parser')
module.exports = app => {
	app.use(bodyParser.json())
	app.get('/api/list', (req, res) => {
		res.send({
			code: 200,
			data: [1, 2, 3, 4, 5]
		})
	})


	app.post('/api/list', async (req, res) => {
		setTimeout(() => {
			res.send({
				code: 200,
				data: [1, 2, 3, 4, 5]
			})
		}, 5000)
	})

	app.delete('/api/list', async (req, res) => {
		setTimeout(() => {
			res.send({
				code: 200,
				data: [1, 2, 3, 4, 5]
			})
		}, 20000)
	})


	app.get('/api/list/:id', (req, res) => {
		const { id } = req.params;

		if (id === '110') {
			res.send({
				code: 200,
				message: 'OK'
			})
		} else {
			res.status(400).send({
				code: 400,
				message: 'no'
			})
		}

	})


	app.post('/123123/1312', (req, res) => {
		qw; qmw; eqwdlw

		qweq

		resss.send({
			code: 200,
			data: [1, 2, 3, 4]
		})
	})


	app.post('/api/login', (req, res) => {
		const { user, pwd } = req.body;
		if (user === 'admin' && pwd === 'admin') {
			res.send({
				code: 200,
				message: 'OK'
			})
		} else {
			res.send({
				code: 400,
				message: '账户密码错误， 请重新登录'
			})
		}
	})
}